import java.io.ObjectInputStream;
 import java.io.FileInputStream;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.IOException;
 import java.io.FileNotFoundException;
 import java.util.Calendar;
 
 public class InflateTime {
  public static void main(String [] args) {
   String filename = "time.ser";
   if(args.length > 0){
       filename = args[0];
   }
   FileInputStream fis = null;
   while (fis == null) {
         try {fis = new FileInputStream(filename);
           }
           catch(FileNotFoundException ex)
           {System.out.println("attesaIn");
               try {Thread.sleep(6000);
                }
                catch(InterruptedException exFNF1)
                {};
            }
   }
     
   ObjectInputStream in = null;
   try {
     in = new ObjectInputStream(fis);
   } catch(IOException ex) {
     ex.printStackTrace();
   }
   
   BufferedReader interact = new BufferedReader(new
InputStreamReader(System.in));
   String input = "";
   PersistentTime time;
   while (input.equals("")) {
   time = null;
   try { 
     while (time == null) {
         try {time = (PersistentTime)in.readObject();
           }
           catch(java.io.EOFException ex)
           {System.out.println("attesaIn");
               try {Thread.sleep(6000);
                }
                catch(InterruptedException exint2)
                {};
           }
     }
    }
    catch(IOException ex)
    {
     ex.printStackTrace();
    }
    catch(ClassNotFoundException ex)
    {
     ex.printStackTrace();
    }
   // print out restored time
    System.out.println("Flattened time: " + time.getTime());
    System.out.println("Current time: " +
Calendar.getInstance().getTime());
    System.out.println("Go?");
     try {input = interact.readLine();
     }
     catch(IOException ex)
     {
       ex.printStackTrace();
     }
   }
   
   
   try
   {
    in.close();
   }
   catch(IOException ex)
   {
     ex.printStackTrace();
   }
 }
}
